<template>
	
	<view class="uni-container">
		<uni-list>
			<uni-list-item v-for="(item,index) in list" :key="index" :title="item.name" note="" @click="goDetailPage(item.url)"></uni-list-item>
		</uni-list>
		
		
		<view class="btn pad10">
			<button type="primary"  @click="test">接口测试</button>
		</view>
		
		
		<br/>
		<view class="">
			{{data}}
		</view>
		<br/>
		<view class="btn pad10" v-if="JSON.stringify(data)!='{}'">
			<button type="primary"  @click="clear">清空</button>
		</view>
		
		<view class="">
			全局配置取值：{{url}}
		</view>
		<view class="uni-padding-wrap uni-common-mt">
			<view class="uni-btn-v">
				<button type="default" @tap="modalTap">有标题的modal</button>
				<button type="default" @tap="noTitlemodalTap">无标题的modal</button>
			</view>
		</view>
		
		<view class="uni-padding-wrap">
			<view class="uni-btn-v">
				<button class="btn-load" type="primary" @click="showLoading">显示 loading 提示框</button>
				<!-- #ifndef MP-ALIPAY -->
				<button @click="hideLoading">隐藏 loading 提示框</button>
				<!-- #endif -->
			</view>
		</view>

		<kmlcTreeSelect title="单选" select-type="single" :default-select="selectData" @onChange="onChange"></kmlcTreeSelect>
		 <view>single:{{selectData}}</view>
		 <kmlcTreeSelect title="多选" select-type="multiple" :default-select="selectDataMul" @onChange="onChange2"></kmlcTreeSelect>
		 <view>multiple:{{selectDataMul}}</view>
	</view>
</template>

<script>
	import  {test}  from '@/pages/work/interface.js'
	import  {gotoPage} from  '@/common/framework/utils/navigate.js' 
import {
	
		DB,
		tools
	} from '@/common/framework'

	import kmlcTreeSelect from  '@/components/kmlc-com/thiskmlc-from-select-user/thiskmlc-from-select-user' 

	export default {
		components:{
			kmlcTreeSelect
		},
		data() {
			return {
				db: DB.init('push-msg'),
				data:{},
				ConversationList:[],
				list:[{
					name:'agv',
					url:'/pages/work/Agv/layout/layout',
				}],
				defaultDataStr:'',
				selectData:[],
				selectDataMul:[],
			};
		},
		onLoad: function (options) {
			this.getConversationList();
			setTimeout(()=>{
				
			},1000)
		},
		 onPullDownRefresh() {
			console.log('refresh');
			this.getConversationList();
			setTimeout(function () {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		mounted(){
			
		},
		computed:{
			url(){
				return getApp().globalData.webApiUrl;
			}
		},
		methods:{
			
			async getConversationList() {
				try {
					let topicItems = await this.db.selectSql("select * from topic where t_userId='" + this.$user.userId +
						"' order by t_isTop desc, t_time desc ");
					if (topicItems && topicItems.length>0) {
						this.ConversationList=topicItems;	
					}
					
					
				} catch (err) {
					console.log(JSON.stringify(err));
					tools.toast('获取对话列表失败');
				}
			
			},
			
			goDetailPage(url){
				gotoPage(url);
			},
			async test(){
				// let ret = await this.$http.get('/kmlc/sys/dict/getDictItems/production_type_code');
				let ret = await test();
				console.log(ret);
				this.data = ret.data;
			},
			clear(){
				this.data ={};
			},
			modalTap: function (e) {
				uni.showModal({
					title: "弹窗标题",
					content: "弹窗内容，告知当前状态、信息和解决方法，描述文字尽量控制在三行内",
					showCancel: false,
					confirmText: "确定"
				})
			},
			noTitlemodalTap: function (e) {
				uni.showModal({
					content: "弹窗内容，告知当前状态、信息和解决方法，描述文字尽量控制在三行内",
					confirmText: "确定",
					cancelText: "取消"
				})
			},
			showLoading: function() {
				uni.showLoading({
					title: 'loading'
				});
			
				// #ifdef MP-ALIPAY
				this._showTimer && clearTimeout(this._showTimer);
				this._showTimer = setTimeout(() => {
					this.hideLoading();
				}, 3000)
				// #endif
			},
			hideLoading: function() {
				uni.hideLoading();
			},
			onChange(data){
				console.log('onChange:',data)
				this.selectData = data;
			},
			onChange2(data){
				console.log('onChange2:',data)
				this.selectDataMul = data;
			}
		}
	}
</script>

<style lang="scss">

</style>
